<template>
  <view class="card-box" :style="{ width, height }">
    <image v-if="img" class="image-box" :src="img" mode="scaleToFill" />
    <slot name="header"></slot>
    <view class="card-inner">
      <slot></slot>
    </view>
  </view>
</template>

<script>
export default {
  name: 'CardBox',
  props: {
    width: { type: String, default: '750rpx' },
    height: { type: String, default: 'auto' },
    img: { type: String, default: '' }
  }
}
</script>

<style lang="scss" scoped>
.card-box {
  position: relative;
  top: 0;
  left: 0;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;

  .image-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  .card-inner {
    width: 100%;
    height: 100%;
    padding: 30rpx 20rpx;
    box-sizing: border-box;
  }
}
</style>